package com.benson.generic;

import java.util.EmptyStackException;

public class Stack<E> {

	private Object[] elements;
	
	private int size;
	
	private static final int DEFAULT_INITIAL_CAPACITY = 16;
	
	public Stack(){
//		elements = new E[DEFAULT_INITIAL_CAPACITY];
		elements = (E[])new Object[]{};
	}
	
	public void push(E e){
		elements[size++]=e;
	}
	
	public E pop(){
		if(size ==0 ){
			throw new EmptyStackException();
		}
		E result = (E)elements[--size];
		elements[size]=null;
		return result;
	}
	
}
